import 'package:flutter/material.dart';

class BusinessCustomerDetailsTagButton extends StatelessWidget {
  final String label;
  final String value;
  final Function onTap;
  final Function onDeleted;
  final Function onDoubleTap;
  final bool isSelected;

  BusinessCustomerDetailsTagButton({
    Key key,
    @required this.label,
    @required this.value,
    this.onDeleted,
    this.onDoubleTap,
    this.onTap,
    this.isSelected = false,
  }) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: onTap,
      onDoubleTap: onDoubleTap,
      borderRadius: BorderRadius.circular(4),
      child: Container(
        padding: EdgeInsets.symmetric(vertical: 6, horizontal: 10),
        decoration: BoxDecoration(
          color: isSelected == false ? Color.fromRGBO(255, 63, 130, 0.09) : Color.fromRGBO(247, 247, 247, 1),
          borderRadius: BorderRadius.circular(4),
        ),
        child: RichText(
          text: TextSpan(children: [
            TextSpan(text: label, style: Theme.of(context).textTheme.bodyText2),
            WidgetSpan(
              child: Visibility(
                visible: onDeleted != null,
                child: InkWell(
                  onTap: onDeleted,
                  child: Container(
                    margin: EdgeInsets.only(left: 6),
                    child: Icon(Icons.close, size: 16, color: Colors.grey),
                  ),
                ),
              ),
            )
          ]),
        ),
      ),
    );
  }
}
